<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	 <meta charset="UTF-8">
	 <title th:replace="common/base::pagetitle"></title>
	 <link th:replace="common/base::static"/>
	 <style type="text/css">

        .layui-form-label {
            width: 190px;
        }
        .layui-input-inline {
            margin-left: 20px;
				width: 100%;
        }
	 </style>
</head>
<body>
<div class="layui-form" style="padding: 20px 30px 0 0;">
	 <fieldset style="border: 0px" disabled>
	 <div class="layui-form-item">
		  <label class="layui-form-label">凭证编号</label>
		  <div class="layui-input-inline">
				<input type="text" name="id" th:value="${editInfo.id}" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">凭证金额（单位：元）</label>
		  <div class="layui-input-inline">
				<input type="text" name="voucherAmount" th:value="${editInfo.voucherAmount}" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">凭证模板</label>
		  <div class="layui-input-inline">
				<select name="templateType" disabled="disabled">
					 <option  value="0" th:selected="${editInfo.templateType == 0}">系统模板</option>
					 <option  value="1" th:selected="${editInfo.templateType == 1}">用户模板</option>
				</select>
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">核心企业</label>
		  <div class="layui-input-inline">
				<select name="bankId" class="form-control" disabled="disabled" th:field="${editInfo.coreEnterpriseId}">
					 <option value="">请选择核心企业</option>
					 <option th:each="core:${coreList}" th:value="${core.id}" th:text="${core.name}"></option>
				</select>
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">平台服务费率（%）</label>
		  <div class="layui-input-inline">
				<input type="text" name="coreEnterpriseName" th:value="0.2" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">手续费（单位：元）</label>
		  <div class="layui-input-inline">
				<input type="text" name="coreEnterpriseName" th:value="${editInfo.voucherAmount * 0.002}" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">保证金余额（单位：元）</label>
		  <div class="layui-input-inline">
				<input type="text" name="coreEnterpriseName" th:value="0" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">接收行</label>
		  <div class="layui-input-inline">
				<select name="bankId" class="form-control" disabled="disabled" th:field="${editInfo.bankId}">
					 <option value="">请选择归属行</option>
					 <option th:each="bank:${bankList}" th:value="${bank.id}" th:text="${bank.name}"></option>
				</select>
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">年化利率（%）</label>
		  <div class="layui-input-inline">
				<input type="text" name="coreEnterpriseName" value="3.2% - 5.0%" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">剩余授信额度（单位：元）</label>
		  <div class="layui-input-inline">
				<input type="text" name="coreEnterpriseName" th:value="0" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
		  </div>
	 </div>
		 <div class="layui-form-item">
<!--			 <label class="layui-form-label">是否同意条款</label>-->
			 <div  id="typeRadio" style="margin-left: 15rem" >
				 <input type="checkbox" lay-verify="otherReq" name="isClause" value="1" lay-skin="switch" lay-text="同意|不同意">
<!--				 <input lay-skin="switch" lay-verify="otherReq" lay-skin="primary"  type="checkbox" name="isClause" value="1"><a  target="_blank" href="/static/file/金融服务合同书模板.pdf">已阅读  <span style="color: #3a8ee6">《金融服务协议》</span></a>-->
			 </div>
			 <div style="margin-left: 20rem;margin-top: -28px;"><a  target="_blank" href="/static/file/金融服务合同书模板.pdf">已阅读  <span style="color: #3a8ee6;font-size: 20px">《金融服务协议》</span></a></div>
		 </div>
	 </fieldset>
	 <div class="layui-form-item layui-hide">
		  <input type="button" lay-submit="" lay-filter="kFormSubmit" id="kFormSubmit" value="确认添加">
		  <input type="text" name="id" th:value="${editInfo.id}" placeholder="保存ID" autocomplete="off" class="layui-input">
		  <!--        <input type="text" name="deptId" th:value="${editInfo.deptId}" placeholder="保存deptId" autocomplete="off" class="layui-input">-->
	 </div>
</div>

<script th:replace="common/base::context"></script>
<script th:replace="common/base::mainjs"></script>
<script th:src="@{/static/js/select-tree.js}"></script>
<script>
    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form;


		//自定义验证规则
		form.verify({
			otherReq: function(value,item){
				var $ = layui.$;
				var verifyName=$(item).attr('name')
						, verifyType=$(item).attr('type')
						,formElem=$(item).parents('.layui-form')//获取当前所在的form元素，如果存在的话
						,verifyElem=formElem.find('input[name='+verifyName+']')//获取需要校验的元素
						,isTrue= verifyElem.is(':checked')//是否命中校验
						,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
				if(!isTrue || !value){
					//定位焦点
					focusElem.css(verifyType=='radio'?{"color":"#FF5722"}:{"border-color":"#FF5722"});
					//对非输入框设置焦点
					focusElem.first().attr("tabIndex","1").css("outline","0").blur(function() {
						focusElem.css(verifyType=='radio'?{"color":""}:{"border-color":""});
					}).focus();
					return '请勾选是否同意条款';
				}
			}
		});

        //监听提交
        form.on('submit(kFormSubmit)', function (data) {
			var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            /*if (deptId) {
                field.deptId = deptId;
            }*/

            log('field=', field);

            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.ajax({
                type: req.type.post,
                url:  BASE_WEB + 'voucher/financing/send',
                data: field,
                async: false,
                success: function (r) {
                    if (r.code === req.status.ok) {
                        parent.layui.table.reload('kContentTable'); //重载表格
                        parent.layer.close(index); //再执行关闭
                    } else {
                        wlbKit.errorMsg(r.msg);
                    }
                }
            });

        });
    })
</script>
</body>
</html>
